home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 2
/
AACD 2.iso
/
AACD
/
WebSites
/
MailingLists
/
AMOSLIST.0599
/
000021_nobody_Wed May 5 06:42:40 1999.msg
< prev
next >
Wrap
Internet Message Format
|
1999-06-01
|
2KB
Received: from onelist.com (pop.onelist.com [209.207.164.13])
by osf1.gmu.edu (8.8.8/8.8.8) with SMTP id GAA18314
for <mcox4@osf1.gmu.edu>; Wed, 5 May 1999 06:42:40 -0400 (EDT)
Received: (qmail 21039 invoked by alias); 5 May 1999 10:42:51 -0000
Received: (qmail 21022 invoked from network); 5 May 1999 10:42:49 -0000
Received: from unknown (HELO saintolaves.demon.co.uk) (195.99.45.58) by pop.onelist.com with SMTP; 5 May 1999 10:42:49 -0000
Date: Wed, 5 May 1999 11:46:58 EST
Message-Id: <199905051146.AA24510676@saintolaves.demon.co.uk>
From: <cheila@saintolaves.demon.co.uk>
X-Sender: <cheila@saintolaves.demon.co.uk>
To: amos-list@onelist.com
X-Mailer: <IMail v4.06>
Mailing-List: list amos-list@onelist.com; contact amos-list-owner@onelist.com
Delivered-To: mailing list amos-list@onelist.com
Precedence: bulk
List-Unsubscribe: <mailto:amos-list-unsubscribe@ONElist.com>
Reply-to: amos-list@onelist.com
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Subject: Re: [amos-list] point in polygon
Status: O
X-Status:
From: <cheila@saintolaves.demon.co.uk>
Hi
The simplest way to check if a point is in a polygon is to
draw a line (in any direction) from your point to way
outside the shape. If the number of intersections of this
line with edges of the polygon is odd, then you are in
the shape, otherwise outside (mmm, topology...). You
might have to be careful about corners though, you might
slip through a non-existent gap or cross twice because of
rounding errors.
This might be slow, but you could always pick a simple line
(always horizontal, say) and optimise the line intersection
calculation for that (check y bounding box first, and only
one edge of x box).
I did read a good book on it ages ago, with all the algorithms
you would ever need (including line drawing, polygon filling,
drawing circles, splines, and other mad stuff in 2d and 3d),
I think it was called Fundamentals of Interactive Computer
Graphics but I'm not sure.
Incidentally, are you using integers or floats? I'm not too
good at using integers (need to many "tricks"), but floats
are slow.
Claude
------------------------------------------------------------------------
Join the Star Wars craze!
http://www.onelist.com
Set up your Star Wars list at ONElist.
------------------------------------------------------------------------
Official AMOS WWW: http://members.xoom.com/AmosFactory/front.html